********************************************************************************
*																		       *
* 			WHY DO PEOPLE USE INFORMAL JUSTICE? REPLICATION (JEPS)			   *
*								     									       *
********************************************************************************

	


* define data and results paths (fill in with your own URL)
	global PathData = "/Users/krzysztofkrakowski/Dropbox/Kosovo project/2_Orders/1_Data/"
	global PathTab = "/Users/krzysztofkrakowski/Dropbox/Kosovo project/2_Orders/4_Writing/z_tables/to_edit/"
	global PathFig = "/Users/krzysztofkrakowski/Dropbox/Kosovo project/2_Orders/4_Writing/z_figures/"
	

* upload the main data file (with original survey)
	use "${PathData}kosovo_survey.dta", clear

* merge data with population grid (250m x 250m) identifiers
merge 1:1 ID using "${PathData}250x250grid.dta", nogenerate force

* merge data with official municipality codes 
merge 1:1 ID using "${PathData}survey_munid.dta", nogenerate force

* merge data with respondents' distance from Prishtina (calculated separately in QGIS)
merge 1:1 ID using "${PathData}dist_prishtina.dta", nogenerate force

* merge data indicating number of courts in a municipality
merge m:1 join_XK_NAME using "${PathData}courts_munid.dta", nogenerate force
replace courts = 0 if courts==.

* merge data including information on population size of a municipality
merge m:1 KOMUNA using "${PathData}population_mun.dta",  force




*** prepare outcome in three steps


* first use lower cases in vignette strings
gen orders_1 = lower(VINJETA1RANDOM)
gen orders_2 = lower(VINJETA2RANDOM)


* identify vignette type by keywords
	* debt *
gen orders_1_civil_debt = strpos(orders_1,"borg") 
replace orders_1_civil_debt = orders_1_civil_debt>0
gen orders_2_civil_debt = strpos(orders_2,"borg") 
replace orders_2_civil_debt = orders_2_civil_debt>0
	* inheritance *
gen orders_1_civil_inheritance =  strpos(orders_1,"toke")
replace orders_1_civil_inheritance = orders_1_civil_inheritance>0
gen orders_2_civil_inheritance = strpos(orders_2,"toke")
replace orders_2_civil_inheritance = orders_2_civil_inheritance>0
	* domestic violence *
gen orders_1_criminal_domestic = strpos(orders_1,"rrahur") 
replace orders_1_criminal_domestic = orders_1_criminal_domestic>0 
gen orders_2_criminal_domestic = strpos(orders_2,"rrahur")
replace orders_2_criminal_domestic = orders_2_criminal_domestic>0 
	* murder *
gen orders_1_criminal_murder = strpos(orders_1,"rinj")
replace orders_1_criminal_murder = orders_1_criminal_murder>0  
gen orders_2_criminal_murder = strpos(orders_2,"rinj")
replace orders_2_criminal_murder = orders_2_criminal_murder>0  



* code outcome variables 
    * debt *
gen legal_civil_debt=. 
replace legal_civil_debt=PERGJIGJJETAI1 if orders_1_civil_debt==1
replace legal_civil_debt=PERGJIGJJETAI2 if orders_2_civil_debt==1
    * inheritance *
gen legal_civil_inheritance=. 
replace legal_civil_inheritance=PERGJIGJJETAI1 if orders_1_civil_inheritance==1
replace legal_civil_inheritance=PERGJIGJJETAI2 if orders_2_civil_inheritance==1
    * domestic violence *
gen legal_criminal_domestic=. 
replace legal_criminal_domestic=PERGJIGJJETAI1 if orders_1_criminal_domestic==1
replace legal_criminal_domestic=PERGJIGJJETAI2 if orders_2_criminal_domestic==1
    * murder *
gen legal_criminal_murder=. 
replace legal_criminal_murder=PERGJIGJJETAI1 if orders_1_criminal_murder==1
replace legal_criminal_murder=PERGJIGJJETAI2 if orders_2_criminal_murder==1




*** prepare treatment variables in two steps
 

* decode treatments by keywords (in vigentte 1)
    * resorucelessnesss (vignette 1)
gen orders_1_t1 = strpos(orders_1,"varf") + strpos(orders_1,"dob")
replace orders_1_t1 = orders_1_t1>0
    * inefficiency (vignette 1)
gen orders_1_t2 = strpos(orders_1,"ngadal")
replace orders_1_t2 = orders_1_t2>0
    * conventions (vignette 1)
gen orders_1_t3 = strpos(orders_1,"nuk p")
replace orders_1_t3 = orders_1_t3>0

* decode treatments by keywords (in vigentte 2)
    * resorucelessnesss (vignette 2)
gen orders_2_t1 = strpos(orders_2,"varf") + strpos(orders_2,"dob")
replace orders_2_t1 = orders_2_t1>0
    * inefficiency (vignette 2)
gen orders_2_t2 = strpos(orders_2,"ngadal")
replace orders_2_t2 = orders_2_t2>0
    * conventions (vignette 2)
gen orders_2_t3 = strpos(orders_2,"nuk p")
replace orders_2_t3 = orders_2_t3>0



* code treatment variables 
    * resourcelessness, debt *
gen legal_civil_debt_t1=. 
replace legal_civil_debt_t1=orders_1_t1 if orders_1_civil_debt==1
replace legal_civil_debt_t1=orders_2_t1 if orders_2_civil_debt==1
    * resourcelessness, inheritance *
gen legal_civil_inheritance_t1=. 
replace legal_civil_inheritance_t1=orders_1_t1 if orders_1_civil_inheritance==1
replace legal_civil_inheritance_t1=orders_2_t1 if orders_2_civil_inheritance==1
    * resourcelessness, domestic violence *
gen legal_criminal_domestic_t1=. 
replace legal_criminal_domestic_t1=orders_1_t1 if orders_1_criminal_domestic==1
replace legal_criminal_domestic_t1=orders_2_t1 if orders_2_criminal_domestic==1
    * resourcelessness, murder *
gen legal_criminal_murder_t1=. 
replace legal_criminal_murder_t1=orders_1_t1 if orders_1_criminal_murder==1
replace legal_criminal_murder_t1=orders_2_t1 if orders_2_criminal_murder==1

    * inefficiency, debt *
gen legal_civil_debt_t2=. 
replace legal_civil_debt_t2=orders_1_t2 if orders_1_civil_debt==1
replace legal_civil_debt_t2=orders_2_t2 if orders_2_civil_debt==1
    * inefficiency, inheritance *
gen legal_civil_inheritance_t2=. 
replace legal_civil_inheritance_t2=orders_1_t2 if orders_1_civil_inheritance==1
replace legal_civil_inheritance_t2=orders_2_t2 if orders_2_civil_inheritance==1
    * inefficiency, domestic violence *
gen legal_criminal_domestic_t2=. 
replace legal_criminal_domestic_t2=orders_1_t2 if orders_1_criminal_domestic==1
replace legal_criminal_domestic_t2=orders_2_t2 if orders_2_criminal_domestic==1
    * inefficiency, murder *
gen legal_criminal_murder_t2=. 
replace legal_criminal_murder_t2=orders_1_t2 if orders_1_criminal_murder==1
replace legal_criminal_murder_t2=orders_2_t2 if orders_2_criminal_murder==1

    * conventions, debt *
gen legal_civil_debt_t3=. 
replace legal_civil_debt_t3=orders_1_t3 if orders_1_civil_debt==1
replace legal_civil_debt_t3=orders_2_t3 if orders_2_civil_debt==1
    * conventions, inheritance *
gen legal_civil_inheritance_t3=. 
replace legal_civil_inheritance_t3=orders_1_t3 if orders_1_civil_inheritance==1
replace legal_civil_inheritance_t3=orders_2_t3 if orders_2_civil_inheritance==1
    * conventions, domestic violence *
gen legal_criminal_domestic_t3=. 
replace legal_criminal_domestic_t3=orders_1_t3 if orders_1_criminal_domestic==1
replace legal_criminal_domestic_t3=orders_2_t3 if orders_2_criminal_domestic==1
    * conventions, murder *
gen legal_criminal_murder_t3=. 
replace legal_criminal_murder_t3=orders_1_t3 if orders_1_criminal_murder==1
replace legal_criminal_murder_t3=orders_2_t3 if orders_2_criminal_murder==1




*** recode outcomes in binary variables (state vs nonstate justice)

    * debt *
gen legal_civil_debt_bin=1 if legal_civil_debt>1
replace legal_civil_debt_bin=0 if legal_civil_debt==1
    * inheritance *
gen legal_civil_inheritance_bin=1 if legal_civil_inheritance>1
replace legal_civil_inheritance_bin=0 if legal_civil_inheritance==1
    * domestic violence *
gen legal_criminal_domestic_bin=1 if legal_criminal_domestic>1
replace legal_criminal_domestic_bin=0 if legal_criminal_domestic==1
    * murder *
gen legal_criminal_murder_bin=1 if legal_criminal_murder>1
replace legal_criminal_murder_bin=0 if legal_criminal_murder==1




*** label variables

label variable	legal_civil_debt "Justice type (debt)"
label variable	legal_civil_inheritance "Justice type (inheritance)"
label variable	legal_criminal_domestic "Justice type (domestic violence)"
label variable	legal_criminal_murder "Justice type (murder)"

label variable	legal_civil_debt_bin "State justice (debt)"
label variable	legal_civil_inheritance_bin "State justice (inheritance)"
label variable	legal_criminal_domestic_bin "State justice (domestic violence)"
label variable	legal_criminal_murder_bin "State justice (murder)"

label define justice_types 1 "State justice" 2 "Religious justice" 3 "Community justice"
label values	legal_civil_debt justice_types
label values	legal_civil_inheritance justice_types
label values	legal_criminal_domestic justice_types
label values	legal_criminal_murder justice_types

label variable	legal_civil_debt_t1 "Resourcelessness"
label variable	legal_civil_debt_t2 "Inefficiency"
label variable	legal_civil_debt_t3 "Conventions"
label variable	legal_civil_inheritance_t1 "Resourcelessness"
label variable	legal_civil_inheritance_t2 "Inefficiency"
label variable	legal_civil_inheritance_t3 "Conventions"
label variable	legal_criminal_domestic_t1 "Resourcelessness"
label variable	legal_criminal_domestic_t2 "Inefficiency"
label variable	legal_criminal_domestic_t3 "Conventions"
label variable	legal_criminal_murder_t1 "Resourcelessness"
label variable	legal_criminal_murder_t2 "Inefficiency"
label variable	legal_criminal_murder_t3 "Conventions"


* standardize variables and label
zval legal_civil_debt_bin legal_civil_inheritance_bin legal_criminal_domestic_bin legal_criminal_murder_bin    legal_civil_debt_t1 legal_civil_debt_t2 legal_civil_debt_t3 legal_civil_inheritance_t1  legal_civil_inheritance_t2  legal_civil_inheritance_t3     legal_criminal_domestic_t1  legal_criminal_domestic_t2  legal_criminal_domestic_t3  legal_criminal_murder_t1    legal_criminal_murder_t2    legal_criminal_murder_t3
label variable  z_legal_civil_debt_t1 "Resourcelessness (z)"
label variable  z_legal_civil_debt_t2 "Inefficiency (z)"
label variable  z_legal_civil_debt_t3 "Conventions (z)"
label variable  z_legal_civil_inheritance_t1 "Resourcelessness (z)"
label variable  z_legal_civil_inheritance_t2 "Inefficiency (z)"
label variable  z_legal_civil_inheritance_t3 "Conventions (z)"
label variable  z_legal_criminal_domestic_t1 "Resourcelessness (z)"
label variable  z_legal_criminal_domestic_t2 "Inefficiency (z)"
label variable  z_legal_criminal_domestic_t3 "Conventions (z)"
label variable  z_legal_criminal_murder_t1 "Resourcelessness (z)"
label variable  z_legal_criminal_murder_t2 "Inefficiency (z)"
label variable  z_legal_criminal_murder_t3 "Conventions (z)"




*** code controls
gen income = ln(Q33)
recode Q27 1=5 2=4 3=3 4=2 5=1, gen(religiosity)
recode Q24 1=1 2=0 3/4=., gen(victim)
recode Q16 1/6=0 7=1, gen(unemployed)




*** code respondents' own legal preferences 
    * debt *
gen legal_debt_own=. 
replace legal_debt_own=PERGJIJETAI1 if orders_1_civil_debt==1
replace legal_debt_own=PERGJIJETAI21 if orders_2_civil_debt==1
    * inheritance *
gen legal_inheritance_own=. 
replace legal_inheritance_own=PERGJIJETAI1 if orders_1_civil_inheritance==1
replace legal_inheritance_own=PERGJIJETAI21 if orders_2_civil_inheritance==1
    * domestic violence *
gen legal_domestic_own=. 
replace legal_domestic_own=PERGJIJETAI1 if orders_1_criminal_domestic==1
replace legal_domestic_own=PERGJIJETAI21 if orders_2_criminal_domestic==1
    * murder *
gen legal_murder_own=. 
replace legal_murder_own=PERGJIJETAI1 if orders_1_criminal_murder==1
replace legal_murder_own=PERGJIJETAI21 if orders_2_criminal_murder==1

* dichotomize respondents' own legal preferences
recode	legal_debt_own (1 = 0) (2 3 = 1), gen(legal_debt_own_bin)
recode	legal_inheritance_own (1 = 0) (2 3 = 1), gen(legal_inheritance_own_bin)
recode	legal_domestic_own (1 = 0) (2 3 = 1), gen(legal_domestic_own_bin)
recode	legal_murder_own (1 = 0) (2 3 = 1), gen(legal_murder_own_bin)




*** code respondent-level indicators of resourcelessness, beliefs about state justice inefficiency and average legal preferences in their municipalities
recode Q34 (1 2 = 0) (3 = 1), gen(treat1)
recode Q8 (1/3 = 0) (4/5 = 1), gen(treat2)
bysort KOMUNA: egen treat3_debt=mean(legal_debt_own_bin) if legal_debt_own_bin!=.
bysort KOMUNA: egen treat3_inheritance=mean(legal_inheritance_own_bin) if legal_inheritance_own_bin!=.
bysort KOMUNA: egen treat3_domestic=mean(legal_domestic_own_bin) if legal_domestic_own_bin!=.
bysort KOMUNA: egen treat3_murder=mean(legal_murder_own_bin) if legal_murder_own_bin!=.
    * dichotomize average legal preferences in respondents' municipalities (to have an indicator whether the majority uses informal justice or not)
recode	treat3_debt (0/.5 = 0) (.5000000001/1 = 1)
recode	treat3_inheritance (0/.5 = 0) (.5000000001/1 = 1)
recode	treat3_domestic  (0/.5 = 0) (.5000000001/1 = 1)
recode	treat3_murder (0/.5 = 0) (.5000000001/1 = 1)
    * label additional variables
label variable treat1 "Resourcelessness"
label variable treat2 "Inefficiency"
label variable treat3_debt "Conventions"
label variable treat3_inheritance "Conventions"
label variable treat3_domestic "Conventions"
label variable treat3_murder "Conventions"
* standardize additional variables and label
zval legal_debt_own_bin legal_inheritance_own_bin legal_domestic_own_bin legal_murder_own_bin  treat1	treat2	treat3_debt	treat3_inheritance	treat3_domestic	treat3_murder
label variable z_treat1 "Resourcelessness"
label variable z_treat2 "Inefficiency"
label variable z_treat3_debt "Conventions"
label variable z_treat3_inheritance "Conventions"
label variable z_treat3_domestic "Conventions"
label variable z_treat3_murder "Conventions"





* code additional accessibility and efficiency proxies (for respondent's preferences analysis)
gen lawyer = 0
replace lawyer = 1 if Q18=="Law, Public Safety, Corrections and Security"
bysort join_ID: egen lawyer_sum=sum(lawyer)
recode lawyer_sum 1/3 = 1
recode Q8 1=5 2=4 3=3 4=2 5=1, gen(trust)
bysort KOMUNA: egen trust_mean=mean(trust)
gen courts_pop = courts/(population/1000)
gen prishtina = 0 
replace prishtina = 1 if KOMUNA==27
    * standardize variables and label
zval Q11_3 Q11_6 lawyer_sum trust_mean courts_pop
label variable z_Q11_3 "Police station nearby"
label variable z_Q11_6 "Courts / notary office nearby"
label variable z_lawyer_sum "Lawyer in neighborhood"
label variable z_trust_mean "Trust in state justice in mun"
label variable z_courts_pop "Number of courts in mun"




* interactions between respondent-level treatments and vignette treatment
    * debt *
gen inter1d=z_legal_civil_debt_t1*z_treat1
gen inter2d=z_legal_civil_debt_t2*z_treat2
gen inter3d=z_legal_civil_debt_t3*z_treat3_debt
    * inheritance *
gen inter1i=z_legal_civil_inheritance_t1*z_treat1
gen inter2i=z_legal_civil_inheritance_t2*z_treat2
gen inter3i=z_legal_civil_inheritance_t3*z_treat3_inheritance
    * domestic violence *
gen inter1v=z_legal_criminal_domestic_t1*z_treat1
gen inter2v=z_legal_criminal_domestic_t2*z_treat2
gen inter3v=z_legal_criminal_domestic_t3*z_treat3_domestic
    * murder *
gen inter1m=z_legal_criminal_murder_t1*z_treat1
gen inter2m=z_legal_criminal_murder_t2*z_treat2
gen inter3m=z_legal_criminal_murder_t3*z_treat3_murder

    * standardize variables and label
label variable inter1d "Own x Charact.'s Resources"
label variable inter1i "Own x Charact.'s Resources"
label variable inter1v "Own x Charact.'s Resources"
label variable inter1m "Own x Charact.'s Resources"
label variable inter2d "Own x Charact.'s Effic. Concerns"
label variable inter2i "Own x Charact.'s Effic. Concerns"
label variable inter2v "Own x Charact.'s Effic. Concerns"
label variable inter2m "Own x Charact.'s Effic. Concerns"
label variable inter3d "Own x Charact.'s Conventions"
label variable inter3i "Own x Charact.'s Conventions"
label variable inter3v "Own x Charact.'s Conventions"
label variable inter3m "Own x Charact.'s Conventions"




* interactions between respondent-level resourcelessness and distance to Prishitna
zval dist_prishtina
gen inter_prishtina=z_dist_prishtina*z_treat1







*** produce tables and figures
    * tables need to be slightly edited manually before including in the LaTex manuscript 



* Figure 1
eststo clear
eststo Debt: reg z_legal_civil_debt_bin z_legal_civil_debt_t1 z_legal_civil_debt_t2 z_legal_civil_debt_t3
eststo Inheritance: reg z_legal_civil_inheritance_bin z_legal_civil_inheritance_t1 z_legal_civil_inheritance_t2 z_legal_civil_inheritance_t3
eststo Domestic_violence: reg z_legal_criminal_domestic_bin z_legal_criminal_domestic_t1 z_legal_criminal_domestic_t2 z_legal_criminal_domestic_t3
eststo Murder: reg z_legal_criminal_murder_bin z_legal_criminal_murder_t1 z_legal_criminal_murder_t2 z_legal_criminal_murder_t3
coefplot Debt, keep(z_legal_civil_debt_t1 z_legal_civil_debt_t2 z_legal_civil_debt_t3) xline(0) horizontal byopts(xrescale) level(95 90) title("Debt") label legend(off) saving(fig1, replace) plotregion(lcolor(black)) xlabel(,grid nogextend ) ylabel(,grid nogextend ) 
coefplot Inheritance, keep(z_legal_civil_inheritance_t1 z_legal_civil_inheritance_t2 z_legal_civil_inheritance_t3) xline(0) horizontal byopts(xrescale) level(95 90) title("Inheritance") label legend(off) saving(fig2, replace) plotregion(lcolor(black)) xlabel(,grid nogextend ) ylabel(,grid nogextend )
coefplot Domestic_violence, keep(z_legal_criminal_domestic_t1 z_legal_criminal_domestic_t2 z_legal_criminal_domestic_t3) xline(0) horizontal byopts(xrescale) level(95 90) title("Domestic violence") label legend(off) saving(fig3, replace) plotregion(lcolor(black)) xlabel(,grid nogextend ) ylabel(,grid nogextend )
coefplot Murder, keep(z_legal_criminal_murder_t1 z_legal_criminal_murder_t2 z_legal_criminal_murder_t3) xline(0) horizontal byopts(xrescale) level(95 90) title("Murder") label legend(off) saving(fig4, replace) plotregion(lcolor(black)) xlabel(,grid nogextend ) ylabel(,grid nogextend )
graph combine fig2.gph fig1.gph fig3.gph  fig4.gph , xcommon 
graph export "${PathFig}Figure1.eps", as(eps) replace 




* Table A1
eststo clear
eststo Debt: reg z_legal_civil_debt_bin z_legal_civil_debt_t1 z_legal_civil_debt_t2 z_legal_civil_debt_t3
eststo Inheritance: reg z_legal_civil_inheritance_bin z_legal_civil_inheritance_t1 z_legal_civil_inheritance_t2 z_legal_civil_inheritance_t3
eststo Domestic_violence: reg z_legal_criminal_domestic_bin z_legal_criminal_domestic_t1 z_legal_criminal_domestic_t2 z_legal_criminal_domestic_t3
eststo Murder: reg z_legal_criminal_murder_bin z_legal_criminal_murder_t1 z_legal_criminal_murder_t2 z_legal_criminal_murder_t3
esttab Debt Inheritance Domestic_violence Murder using "${PathTab}TableA1.tex", b(3) se(3) star(* 0.1 ** 0.05 *** 0.01) drop(_cons) stats(r2 N, labels("R-squared" "N")) label nodepvar mtitles title("State vs Nonstate Justice") replace nonotes postfoot(" ")




* Table A2
eststo clear
eststo Debt: reg z_legal_civil_debt_bin z_legal_civil_debt_t1 z_legal_civil_debt_t2 z_legal_civil_debt_t3 i.Q2 Q3 i.Q4 i.Q16 income religiosity 
eststo Inheritance: reg z_legal_civil_inheritance_bin z_legal_civil_inheritance_t1 z_legal_civil_inheritance_t2 z_legal_civil_inheritance_t3 i.Q2 Q3 i.Q4 i.Q16 income religiosity 
eststo Domestic_violence: reg z_legal_criminal_domestic_bin z_legal_criminal_domestic_t1 z_legal_criminal_domestic_t2 z_legal_criminal_domestic_t3 i.Q2 Q3 i.Q4 i.Q16 income religiosity 
eststo Murder: reg z_legal_criminal_murder_bin z_legal_criminal_murder_t1 z_legal_criminal_murder_t2 z_legal_criminal_murder_t3 i.Q2 Q3 i.Q4 i.Q16 income religiosity 
esttab Debt Inheritance Domestic_violence Murder using "${PathTab}TableA2.tex", b(3) se(3) star(* 0.1 ** 0.05 *** 0.01) drop(_cons) stats(r2 N, labels("R-squared" "N")) label nodepvar mtitles title("State vs Nonstate Justice") replace nonotes postfoot(" ")




* Table A3
eststo clear
eststo Debt: reg z_legal_civil_debt_bin z_legal_civil_debt_t1 z_legal_civil_debt_t2 z_legal_civil_debt_t3 i.Q2 Q3 i.Q4 i.Q16 income religiosity [pw=Weights]
eststo Inheritance: reg z_legal_civil_inheritance_bin z_legal_civil_inheritance_t1 z_legal_civil_inheritance_t2 z_legal_civil_inheritance_t3 i.Q2 Q3 i.Q4 i.Q16 income religiosity [pw=Weights]
eststo Domestic_violence: reg z_legal_criminal_domestic_bin z_legal_criminal_domestic_t1 z_legal_criminal_domestic_t2 z_legal_criminal_domestic_t3 i.Q2 Q3 i.Q4 i.Q16 income religiosity [pw=Weights]
eststo Murder: reg z_legal_criminal_murder_bin z_legal_criminal_murder_t1 z_legal_criminal_murder_t2 z_legal_criminal_murder_t3 i.Q2 Q3 i.Q4 i.Q16 income religiosity [pw=Weights]
esttab Debt Inheritance Domestic_violence Murder using "${PathTab}TableA3.tex", b(3) se(3) star(* 0.1 ** 0.05 *** 0.01) drop(_cons) stats(r2 N, labels("R-squared" "N")) label nodepvar mtitles title("State vs Nonstate Justice") replace nonotes postfoot(" ")




* Table A4
eststo clear
eststo Debt:  mlogit legal_civil_debt legal_civil_debt_t1 legal_civil_debt_t2 legal_civil_debt_t3
eststo Inheritance: mlogit legal_civil_inheritance legal_civil_inheritance_t1 legal_civil_inheritance_t2 legal_civil_inheritance_t3
eststo Domestic_violence: mlogit legal_criminal_domestic legal_criminal_domestic_t1 legal_criminal_domestic_t2 legal_criminal_domestic_t3
eststo Murder: mlogit legal_criminal_murder legal_criminal_murder_t1 legal_criminal_murder_t2 legal_criminal_murder_t3
esttab Debt Inheritance Domestic_violence Murder using "${PathTab}TableA4.tex", b(3) se(3) star(* 0.1 ** 0.05 *** 0.01) drop(_cons) stats(r2 N, labels("R-squared" "N")) label nodepvar mtitles title("State vs Nonstate Justice") replace nonotes postfoot(" ")




* Figure A2
    * prepare four sub-figures seprately

    * Figure A2(a) - debt
preserve
reg legal_civil_debt_bin i.legal_civil_debt_t1##i.legal_civil_debt_t2##i.legal_civil_debt_t3
margins, dydx(legal_civil_debt_t3) at(legal_civil_debt_t1 = (0 (1) 1) legal_civil_debt_t2 = (0 (1) 1))
        _marg_save, saving(temp, replace)
        use temp, clear
        twoway contour _margin _at1 _at2, ccut(-0.05(.05)0.15) title(Debt) ztitle(Effect of conventions) name(margins3d_try1, replace)
graph export "${PathFig}FigureA2a.png", as(png) replace
restore
    * Figure A2(b) - domestic violence
preserve
reg legal_criminal_domestic_bin i.legal_criminal_domestic_t1##i.legal_criminal_domestic_t2##i.legal_criminal_domestic_t3
margins, dydx(legal_criminal_domestic_t3) at(legal_criminal_domestic_t1 = (0 (1) 1) legal_criminal_domestic_t2 = (0 (1) 1))
        _marg_save, saving(temp, replace)
        use temp, clear
        twoway contour _margin _at1 _at2, ccut(-0.05(.05)0.15) title(Domestic violence) ztitle(Effect of conventions) name(margins3d_try1, replace)
graph export "${PathFig}FigureA2b.png", as(png) replace
restore
    * Figure A2(c) - inheritance
preserve
reg legal_civil_inheritance_bin i.legal_civil_inheritance_t1##i.legal_civil_inheritance_t2##i.legal_civil_inheritance_t3
margins, dydx(legal_civil_inheritance_t3) at(legal_civil_inheritance_t1 = (0 (1) 1) legal_civil_inheritance_t2 = (0 (1) 1))
        _marg_save, saving(temp, replace)
        use temp, clear
        twoway contour _margin _at1 _at2, ccut(-0.05(.05)0.15) title(Inheritance) ztitle(Effect of conventions) name(margins3d_try1, replace)
graph export "${PathFig}FigureA2c.png", as(png) replace
restore
    * Figure A2(d) - murder
preserve
reg legal_criminal_murder_bin i.legal_criminal_murder_t1##i.legal_criminal_murder_t2##i.legal_criminal_murder_t3
margins, dydx(legal_criminal_murder_t3) at(legal_criminal_murder_t1 = (0 (1) 1) legal_criminal_murder_t2 = (0 (1) 1))
        _marg_save, saving(temp, replace)
        use temp, clear
        twoway contour _margin _at1 _at2, ccut(-0.05(.05)0.15) title(Murder) ztitle(Effect of conventions) name(margins3d_try1, replace)
graph export "${PathFig}FigureA2d.png", as(png) replace
restore




* Table A5
eststo clear
eststo Debt: reg z_legal_debt_own_bin z_treat1 z_treat2 z_treat3_debt i.Q2 Q3 i.Q4 i.Q16 income religiosity [pw=Weights]
eststo Inheritance: reg z_legal_inheritance_own_bin z_treat1 z_treat2 z_treat3_inheritance i.Q2 Q3 i.Q4 i.Q16 income religiosity [pw=Weights]
eststo Domestic_violence: reg z_legal_domestic_own_bin z_treat1 z_treat2 z_treat3_domestic i.Q2 Q3 i.Q4 i.Q16 income religiosity [pw=Weights]
eststo Murder: reg z_legal_murder_own_bin z_treat1 z_treat2 z_treat3_murder i.Q2 Q3 i.Q4 i.Q16 income religiosity [pw=Weights]
esttab Debt Inheritance Domestic_violence Murder using "${PathTab}TableA5.tex", b(3) se(3) star(* 0.1 ** 0.05 *** 0.01) drop(_cons) stats(r2 N, labels("R-squared" "N")) label nodepvar mtitles title("State vs Nonstate Justice") replace nonotes postfoot(" ")




* Table A6
eststo clear
eststo Debt: reg z_legal_debt_own_bin z_treat1 z_treat2 z_treat3_debt Q11_3 Q11_6 lawyer_sum trust_mean courts_pop prishtina i.Q2 Q3 i.Q4 i.Q16 income religiosity [pw=Weights]
eststo Inheritance: reg z_legal_inheritance_own_bin z_treat1 z_treat2 z_treat3_inheritance Q11_3 Q11_6 lawyer_sum trust_mean courts_pop prishtina i.Q2 Q3 i.Q4 i.Q16 income religiosity [pw=Weights]
eststo Domestic_violence: reg z_legal_domestic_own_bin z_treat1 z_treat2 z_treat3_domestic Q11_3 Q11_6 lawyer_sum trust_mean courts_pop prishtina i.Q2 Q3 i.Q4 i.Q16 income religiosity [pw=Weights]
eststo Murder: reg z_legal_murder_own_bin z_treat1 z_treat2 z_treat3_murder Q11_3 Q11_6 lawyer_sum trust_mean courts_pop prishtina i.Q2 Q3 i.Q4 i.Q16 income religiosity [pw=Weights]
esttab Debt Inheritance Domestic_violence Murder using "${PathTab}TableA6.tex", b(3) se(3) star(* 0.1 ** 0.05 *** 0.01) drop(_cons) stats(r2 N, labels("R-squared" "N")) label nodepvar mtitles title("State vs Nonstate Justice") replace nonotes postfoot(" ")




* Figure A3
eststo clear
eststo Debt: reg z_legal_civil_debt_bin z_legal_civil_debt_t1 z_legal_civil_debt_t2 z_legal_civil_debt_t3 z_treat1 z_treat2 z_treat3_debt inter1d inter2d inter3d i.Q2 Q3 i.Q4 i.Q16 income religiosity [pw=Weights]
eststo Inheritance: reg z_legal_civil_inheritance_bin z_legal_civil_inheritance_t1 z_legal_civil_inheritance_t2 z_legal_civil_inheritance_t3 z_treat1 z_treat2 z_treat3_inheritance inter1i inter2i inter3i i.Q2 Q3 i.Q4 i.Q16 income religiosity [pw=Weights]
eststo Domestic_violence: reg z_legal_criminal_domestic_bin z_legal_criminal_domestic_t1 z_legal_criminal_domestic_t2 z_legal_criminal_domestic_t3 z_treat1 z_treat2 z_treat3_domestic inter1v inter2v inter3v i.Q2 Q3 i.Q4 i.Q16 income religiosity [pw=Weights]
eststo Murder: reg z_legal_criminal_murder_bin z_legal_criminal_murder_t1 z_legal_criminal_murder_t2 z_legal_criminal_murder_t3 z_treat1 z_treat2 z_treat3_murder inter1m inter2m inter3m i.Q2 Q3 i.Q4 i.Q16 income religiosity [pw=Weights]
coefplot Debt, keep(inter1d inter2d inter3d) xline(0) horizontal byopts(xrescale) level(95 90) title("Debt") label legend(off) saving(fig1, replace) plotregion(lcolor(black)) xlabel(,grid nogextend ) ylabel(,grid nogextend ) 
coefplot Inheritance, keep(inter1i inter2i inter3i) xline(0) horizontal byopts(xrescale) level(95 90) title("Inheritance") label legend(off) saving(fig2, replace) plotregion(lcolor(black)) xlabel(,grid nogextend ) ylabel(,grid nogextend )
coefplot Domestic_violence, keep(inter1v inter2v inter3v) xline(0) horizontal byopts(xrescale) level(95 90) title("Domestic violence") label legend(off) saving(fig3, replace) plotregion(lcolor(black)) xlabel(,grid nogextend ) ylabel(,grid nogextend )
coefplot Murder, keep(inter1m inter2m inter3m) xline(0) horizontal byopts(xrescale) level(95 90) title("Murder") label legend(off) saving(fig4, replace) plotregion(lcolor(black)) xlabel(,grid nogextend ) ylabel(,grid nogextend )
graph combine fig2.gph fig1.gph fig3.gph  fig4.gph , xcommon 
graph export "${PathFig}FigureA3.png", as(png) replace 




* Table A7
eststo clear
eststo Debt: reg z_legal_civil_debt_bin z_legal_civil_debt_t1 z_legal_civil_debt_t2 z_legal_civil_debt_t3 z_treat1 z_treat2 z_treat3_debt inter1d inter2d inter3d i.Q2 Q3 i.Q4 i.Q16 income religiosity [pw=Weights]
eststo Inheritance: reg z_legal_civil_inheritance_bin z_legal_civil_inheritance_t1 z_legal_civil_inheritance_t2 z_legal_civil_inheritance_t3 z_treat1 z_treat2 z_treat3_inheritance inter1i inter2i inter3i i.Q2 Q3 i.Q4 i.Q16 income religiosity [pw=Weights]
eststo Domestic_violence: reg z_legal_criminal_domestic_bin z_legal_criminal_domestic_t1 z_legal_criminal_domestic_t2 z_legal_criminal_domestic_t3 z_treat1 z_treat2 z_treat3_domestic inter1v inter2v inter3v i.Q2 Q3 i.Q4 i.Q16 income religiosity [pw=Weights]
eststo Murder: reg z_legal_criminal_murder_bin z_legal_criminal_murder_t1 z_legal_criminal_murder_t2 z_legal_criminal_murder_t3 z_treat1 z_treat2 z_treat3_murder inter1m inter2m inter3m i.Q2 Q3 i.Q4 i.Q16 income religiosity [pw=Weights]
esttab Debt Inheritance Domestic_violence Murder using "${PathTab}TableA7.tex", b(3) se(3) star(* 0.1 ** 0.05 *** 0.01) drop(_cons) stats(r2 N, labels("R-squared" "N")) label nodepvar mtitles title("State vs Nonstate Justice") replace nonotes postfoot(" ")





* Table A8
eststo clear
eststo Debt: reg legal_debt_own_bin income 
eststo Inheritance: reg legal_inheritance_own_bin income 
eststo Domestic_violence: reg legal_domestic_own_bin income 
eststo Murder: reg legal_murder_own_bin income 
esttab Debt Inheritance Domestic_violence Murder using "${PathTab}TableA8.tex", b(3) se(3) star(* 0.1 ** 0.05 *** 0.01) keep(income) stats(r2 N, labels("R-squared" "N")) label nodepvar mtitles title("Preference for Nonstate Justice and Income") replace nonotes postfoot(" ")





* Table A9
eststo clear
eststo Debt: reg z_legal_debt_own_bin z_treat1 z_treat2 z_treat3_debt i.Q2 Q3 i.Q4 i.Q16 income religiosity z_dist_prishtina inter_prishtina [pw=Weights]
eststo Inheritance: reg z_legal_inheritance_own_bin z_treat1 z_treat2 z_treat3_inheritance i.Q2 Q3 i.Q4 i.Q16 income religiosity z_dist_prishtina inter_prishtina [pw=Weights]
eststo Domestic_violence: reg z_legal_domestic_own_bin z_treat1 z_treat2 z_treat3_domestic i.Q2 Q3 i.Q4 i.Q16 income religiosity z_dist_prishtina inter_prishtina [pw=Weights]
eststo Murder: reg z_legal_murder_own_bin z_treat1 z_treat2 z_treat3_murder i.Q2 Q3 i.Q4 i.Q16 income religiosity z_dist_prishtina inter_prishtina [pw=Weights]
esttab Debt Inheritance Domestic_violence Murder using "${PathTab}TableA9.tex", b(3) se(3) star(* 0.1 ** 0.05 *** 0.01) drop(_cons) stats(r2 N, labels("R-squared" "N")) label nodepvar mtitles title("State vs Nonstate Justice") replace nonotes postfoot(" ")




